package gwtgaetools.client;

import gwtgaetools.client.comm.GenericClientRPC;
import gwtgaetools.client.comm.GenericMessageInterpreter;
import gwtgaetools.client.comm.GenericRPCServiceAsync;
import gwtgaetools.client.ui.GenericAppDisplay;
import gwtgaetools.shared.model.GenericMessage;

import com.google.gwt.core.client.EntryPoint;

public abstract class GenericAppController<
Type,
MainObject,
Message extends GenericMessage<Type>, 
MessageInterpreter extends GenericMessageInterpreter<Type, Message, ?>, 
RPCService extends GenericRPCServiceAsync<Type, Message>, 
ClientRPC extends GenericClientRPC<Type, MainObject, RPCService, Message, MessageInterpreter>, 
AppDisplay extends GenericAppDisplay<Type, MainObject, Message, RPCService, MessageInterpreter, ClientRPC>
> 
implements EntryPoint {

	AppDisplay appDisplay;

	ClientRPC clientRPC;

	MainObject dataModel;
	
	public void onModuleLoad() {

		dataModel = initData();
		
		clientRPC = initRPC(dataModel);
		
		appDisplay = initDisplay(dataModel, clientRPC);
	
	}
	
	public abstract MainObject initData();
	
	public abstract ClientRPC initRPC(MainObject t);
	
	public abstract AppDisplay initDisplay(MainObject t, ClientRPC s);
}
